﻿using System.Collections.Generic;
using System.Linq;
using System.Threading.Tasks;
using Furion.DatabaseAccessor;
using Furion.DependencyInjection;
using Furion.DynamicApiController;
using Furion.FriendlyException;
using Mapster;
using Microsoft.AspNetCore.Mvc;

using SqlSugar;

using GnpFine.Core;

namespace GnpFine.Application.NmpaSystem
{
    /// <summary>
    /// 药监服务
    /// </summary>
    [ApiDescriptionSettings(Name = "nmpa", Order = 100)]
    public class NmpaService : INmpaService, IDynamicApiController, IScoped
    {

        private readonly ISqlSugarClient db; // 核心对象：拥有完整的SqlSugar全部功能

        public NmpaService()
        {
             db =App.GetService<ISqlSugarClient>();//用手动获取方式支持切换仓储

        }


        /// <summary>
        /// 增加入库
        /// </summary>
        /// <param name="input"></param>
        /// <returns></returns>
        [HttpPost("/nmpaSugerStock/add")]
        public int AddSugerStock(STOCK input)
        {
            return db.Insertable(input).ExecuteCommand();

        }

        /// <summary>
        /// 增加出库surger ORM
        /// </summary>
        /// <param name="input"></param>
        /// <returns></returns>
        [HttpPost("/nmpaSugerSale/add")]
        public int AddSugerSale(SALE input)
        {
            return db.Insertable(input).ExecuteCommand();
            //db.Ado.ExecuteCommand("delete  from [SALE] ");
        }


        /// <summary>
        /// 增加库存
        /// </summary>
        /// <param name="input"></param>
        /// <returns></returns>
        [HttpPost("/nmpaSugerStore/add")]
        public int AddSugerStore(STORE input)
        {
            return db.Insertable(input).ExecuteCommand();
        }

    }
}
